import java.awt.Event;
import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.SpinnerNumberModel;
import javax.swing.UIManager;
import javax.swing.border.Border;

/**
 *
 * @author Zuzka Krejcova
 */
public class TransformaceApp extends javax.swing.JFrame {

    /** Creates new form TransformaceApp */
    public TransformaceApp() {
        initComponents();
        // nacist config.xml, jestli existuje
        try {
            config = new Configuration();
            fav1.setText(config.getItemConfig(fav1));
            fav2.setText(config.getItemConfig(fav2));
            fav3.setText(config.getItemConfig(fav3));
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        fileChooser = new javax.swing.JFileChooser();
        vyberAkciMenu = new javax.swing.JPopupMenu();
        identitaPopUp = new javax.swing.JMenuItem();
        nenormovanePopUp = new javax.swing.JMenuItem();
        nedosazitelnePopUp = new javax.swing.JMenuItem();
        neRedukovanouPopUp = new javax.swing.JMenuItem();
        epsilonPopUp = new javax.swing.JMenuItem();
        jednoduchaPopUp = new javax.swing.JMenuItem();
        naVlastniPopUp = new javax.swing.JMenuItem();
        chomskyPopUp = new javax.swing.JMenuItem();
        levaRekurzePopUp = new javax.swing.JMenuItem();
        greibachovaPopUp = new javax.swing.JMenuItem();
        nicPopUp = new javax.swing.JMenuItem();
        vytykaniPopUp = new javax.swing.JMenuItem();
        rohovkaPopUp = new javax.swing.JMenuItem();
        generovatGramatikuDialog = new javax.swing.JDialog();
        genGramatika = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        pravidlaText = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        netermyText = new javax.swing.JTextArea();
        jScrollPane5 = new javax.swing.JScrollPane();
        termyText = new javax.swing.JTextArea();
        jSeparator3 = new javax.swing.JSeparator();
        genNetermy = new javax.swing.JButton();
        genTermy = new javax.swing.JButton();
        genKoren = new javax.swing.JButton();
        genPravidla = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JSeparator();
        genZpet = new javax.swing.JButton();
        genOK = new javax.swing.JButton();
        netermyMin = new javax.swing.JSpinner();
        netermyMax = new javax.swing.JSpinner();
        termyMin = new javax.swing.JSpinner();
        termyMax = new javax.swing.JSpinner();
        pravidlaRadkyMin = new javax.swing.JSpinner();
        pravidlaRadkyMax = new javax.swing.JSpinner();
        pravidlaRetezcuMin = new javax.swing.JSpinner();
        pravidlaRetezcuMax = new javax.swing.JSpinner();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        netermyInfo = new javax.swing.JButton();
        netermySmazat = new javax.swing.JButton();
        termySmazat = new javax.swing.JButton();
        termyInfo = new javax.swing.JButton();
        pravidlaSmazat = new javax.swing.JButton();
        pravidlaInfo = new javax.swing.JButton();
        korenDrop = new javax.swing.JTextField();
        novaGenerovatDialog = new javax.swing.JDialog();
        novaGenOK = new javax.swing.JButton();
        novaGenZpet = new javax.swing.JButton();
        novaGramatikaNadpis = new javax.swing.JLabel();
        novaGramatikaRadioButton = new javax.swing.JRadioButton();
        generovatGramatikuRadioButton = new javax.swing.JRadioButton();
        novaGenerovanaGroup = new javax.swing.ButtonGroup();
        novaGramatika1_2_3Dialog = new javax.swing.JDialog();
        novaGramatikaNadpis1 = new javax.swing.JLabel();
        netermNovaTextField = new javax.swing.JTextField();
        netermyNovaDalsi = new javax.swing.JButton();
        netermyNovaZpet = new javax.swing.JButton();
        pridatNeterm = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        netermyNovaList = new javax.swing.JList();
        jScrollPaneNNH = new javax.swing.JScrollPane();
        netermyNovaHint = new javax.swing.JTextArea();
        novaGramatika4Dialog = new javax.swing.JDialog();
        novaGramatikaNadpis2 = new javax.swing.JLabel();
        levaStranaCombo = new javax.swing.JComboBox();
        pravaStranaCombo = new javax.swing.JComboBox();
        pravidloNovaText = new javax.swing.JTextField();
        jScrollPane7 = new javax.swing.JScrollPane();
        pravidlaNovaText = new javax.swing.JTextArea();
        pravidlaDalsi = new javax.swing.JButton();
        pravidlaZpet = new javax.swing.JButton();
        pridatSymbol = new javax.swing.JButton();
        pridatPravidlo = new javax.swing.JButton();
        novaGramatika5Dialog = new javax.swing.JDialog();
        novaGramatikaNadpis3 = new javax.swing.JLabel();
        jScrollPane8 = new javax.swing.JScrollPane();
        gramatikaPrehled = new javax.swing.JTextArea();
        prehledZpet = new javax.swing.JButton();
        prehledHotovo = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        statusPanel = new javax.swing.JPanel();
        status = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea2 = new javax.swing.JTextArea();
        ulozit1 = new javax.swing.JButton();
        pouzit = new javax.swing.JButton();
        ulozit2 = new javax.swing.JButton();
        nahrat = new javax.swing.JButton();
        fav1 = new javax.swing.JButton();
        fav2 = new javax.swing.JButton();
        fav3 = new javax.swing.JButton();
        smazat = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        gramatikaMenu = new javax.swing.JMenu();
        novaGramatikaMenu = new javax.swing.JMenuItem();
        nahratMenu = new javax.swing.JMenuItem();
        ulozitMenu = new javax.swing.JMenu();
        ulozit2Menu = new javax.swing.JMenuItem();
        ulozit1Menu = new javax.swing.JMenuItem();
        exportMenu = new javax.swing.JMenu();
        toXmlMenu = new javax.swing.JMenuItem();
        toLatexMenu = new javax.swing.JMenuItem();
        toHtmlMenu = new javax.swing.JMenuItem();
        toBisonMenu = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        konecMenu = new javax.swing.JMenuItem();
        transformaceMenu = new javax.swing.JMenu();
        identita = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        nenormovane = new javax.swing.JMenuItem();
        nedosazitelne = new javax.swing.JMenuItem();
        naRedukovanou = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        epsilon = new javax.swing.JMenuItem();
        jednoducha = new javax.swing.JMenuItem();
        redukce = new javax.swing.JMenuItem();
        naVlastni = new javax.swing.JMenuItem();
        chomsky = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        levaRekurze = new javax.swing.JMenuItem();
        greibachova = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        vytykani = new javax.swing.JMenuItem();
        rohovaSubstituce = new javax.swing.JMenuItem();
        mezivysledek = new javax.swing.JCheckBoxMenuItem();
        helpMenu = new javax.swing.JMenu();
        napovedaMenu = new javax.swing.JMenuItem();
        oProgramu = new javax.swing.JMenuItem();

        identitaPopUp.setText("identita");
        identitaPopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                identitaPopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(identitaPopUp);

        nenormovanePopUp.setText("odstranit nenormované neterminály");
        nenormovanePopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nenormovanePopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(nenormovanePopUp);

        nedosazitelnePopUp.setText("odstranit nedosažitelné symboly");
        nedosazitelnePopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nedosazitelnePopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(nedosazitelnePopUp);

        neRedukovanouPopUp.setText("na redukovanou gr.");
        neRedukovanouPopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                neRedukovanouPopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(neRedukovanouPopUp);

        epsilonPopUp.setText("eliminace epsilon pravidel");
        epsilonPopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                epsilonPopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(epsilonPopUp);

        jednoduchaPopUp.setText("odstranění jednoduchých pravidel");
        jednoduchaPopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jednoduchaPopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(jednoduchaPopUp);

        naVlastniPopUp.setText("převod na vlastní gr.");
        naVlastniPopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                naVlastniPopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(naVlastniPopUp);

        chomskyPopUp.setText("Chomského NF");
        chomskyPopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chomskyPopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(chomskyPopUp);

        levaRekurzePopUp.setText("odstranění levé rekurze");
        levaRekurzePopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                levaRekurzePopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(levaRekurzePopUp);

        greibachovaPopUp.setText("Greibachové NF");
        greibachovaPopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                greibachovaPopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(greibachovaPopUp);

        nicPopUp.setText("nic");
        nicPopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nicPopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(nicPopUp);

        vytykaniPopUp.setText("levá faktorizace");
        vytykaniPopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vytykaniPopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(vytykaniPopUp);

        rohovkaPopUp.setText("rohová substituce");
        rohovkaPopUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rohovkaPopUpActionPerformed(evt);
            }
        });
        vyberAkciMenu.add(rohovkaPopUp);

        generovatGramatikuDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        generovatGramatikuDialog.setTitle("Nová gramatika");
        generovatGramatikuDialog.setMinimumSize(generovatGramatikuDialog.getPreferredSize());
        generovatGramatikuDialog.setModal(true);
        generovatGramatikuDialog.setModalExclusionType(null);
        generovatGramatikuDialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                generovatGramatikuDialogWindowClosing(evt);
            }
        });

        genGramatika.setText("Generovat náhodnou gramatiku");
        genGramatika.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                genGramatikaActionPerformed(evt);
            }
        });

        pravidlaText.setColumns(10);
        pravidlaText.setFont(new java.awt.Font("DejaVu Sans", 0, 14));
        pravidlaText.setLineWrap(true);
        pravidlaText.setRows(4);
        pravidlaText.setWrapStyleWord(true);
        pravidlaText.setBorder(javax.swing.BorderFactory.createTitledBorder("Pravidla"));
        pravidlaText.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                pravidlaTextPropertyChange(evt);
            }
        });
        jScrollPane3.setViewportView(pravidlaText);

        netermyText.setColumns(10);
        netermyText.setFont(new java.awt.Font("DejaVu Sans", 0, 14));
        netermyText.setLineWrap(true);
        netermyText.setRows(2);
        netermyText.setWrapStyleWord(true);
        netermyText.setBorder(javax.swing.BorderFactory.createTitledBorder("Neterminály"));
        netermyText.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                netermyTextPropertyChange(evt);
            }
        });
        jScrollPane4.setViewportView(netermyText);

        termyText.setColumns(10);
        termyText.setFont(new java.awt.Font("DejaVu Sans", 0, 14));
        termyText.setLineWrap(true);
        termyText.setRows(2);
        termyText.setWrapStyleWord(true);
        termyText.setBorder(javax.swing.BorderFactory.createTitledBorder("Terminály"));
        termyText.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                termyTextPropertyChange(evt);
            }
        });
        jScrollPane5.setViewportView(termyText);

        genNetermy.setText("Generovat neterminály");
        genNetermy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                genNetermyActionPerformed(evt);
            }
        });

        genTermy.setText("Generovat terminály");
        genTermy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                genTermyActionPerformed(evt);
            }
        });

        genKoren.setText("Náhodně zvolit kořen");
        genKoren.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                genKorenActionPerformed(evt);
            }
        });

        genPravidla.setText("Generovat pravidla");
        genPravidla.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                genPravidlaActionPerformed(evt);
            }
        });

        genZpet.setText("Zpět");
        genZpet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                genZpetActionPerformed(evt);
            }
        });

        genOK.setText("OK");
        genOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                genOKActionPerformed(evt);
            }
        });

        netermyMin.setModel(new javax.swing.SpinnerNumberModel(Short.valueOf((short)5), Short.valueOf((short)1), Short.valueOf((short)5), Short.valueOf((short)1)));
        netermyMin.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                netermyMinPropertyChange(evt);
            }
        });

        netermyMax.setModel(new javax.swing.SpinnerNumberModel(Short.valueOf((short)5), Short.valueOf((short)0), null, Short.valueOf((short)1)));
        netermyMax.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                netermyMaxPropertyChange(evt);
            }
        });

        termyMin.setModel(new javax.swing.SpinnerNumberModel(Short.valueOf((short)5), Short.valueOf((short)1), Short.valueOf((short)5), Short.valueOf((short)1)));
        termyMin.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                termyMinPropertyChange(evt);
            }
        });

        termyMax.setModel(new javax.swing.SpinnerNumberModel(Short.valueOf((short)5), Short.valueOf((short)0), null, Short.valueOf((short)1)));
        termyMax.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                termyMaxPropertyChange(evt);
            }
        });

        pravidlaRadkyMin.setModel(new javax.swing.SpinnerNumberModel(Short.valueOf((short)3), Short.valueOf((short)0), Short.valueOf((short)5), Short.valueOf((short)1)));
        pravidlaRadkyMin.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                pravidlaRadkyMinPropertyChange(evt);
            }
        });

        pravidlaRadkyMax.setModel(new javax.swing.SpinnerNumberModel(Short.valueOf((short)5), Short.valueOf((short)3), Short.valueOf((short)5), Short.valueOf((short)1)));
        pravidlaRadkyMax.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                pravidlaRadkyMaxPropertyChange(evt);
            }
        });

        pravidlaRetezcuMin.setModel(new javax.swing.SpinnerNumberModel(Short.valueOf((short)1), Short.valueOf((short)1), Short.valueOf((short)4), Short.valueOf((short)1)));
        pravidlaRetezcuMin.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                pravidlaRetezcuMinPropertyChange(evt);
            }
        });

        pravidlaRetezcuMax.setModel(new javax.swing.SpinnerNumberModel(Short.valueOf((short)4), Short.valueOf((short)1), null, Short.valueOf((short)1)));
        pravidlaRetezcuMax.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                pravidlaRetezcuMaxPropertyChange(evt);
            }
        });

        jLabel1.setText("Pravidel na řádek:");

        jLabel2.setText("maximum");

        jLabel3.setText("Počet neterminálů: minimum");

        jLabel4.setText("maximum");

        jLabel5.setText("Počet terminálů:");

        jLabel6.setText("minimum");

        jLabel7.setText("Počet řádků:");

        jLabel8.setText("maximum");

        jLabel9.setText("minimum");

        jLabel10.setText("minimum");

        jLabel11.setText("maximum");

        netermyInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/info_16.png"))); // NOI18N
        netermyInfo.setToolTipText("<html>Neterminály je možné zadat i ručně - přímo do pole. <br />\nJednotlivé neterminály je třeba oddělit čárkou <br />\n(a případně libovolným počtem bílých znaků).");
        netermyInfo.setContentAreaFilled(false);

        netermySmazat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/delete_16.png"))); // NOI18N
        netermySmazat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                netermySmazatActionPerformed(evt);
            }
        });

        termySmazat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/delete_16.png"))); // NOI18N
        termySmazat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                termySmazatActionPerformed(evt);
            }
        });

        termyInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/info_16.png"))); // NOI18N
        termyInfo.setToolTipText("<html>Terminály je možné zadat i ručně - přímo do pole. <br />\nJednotlivé terminály je třeba oddělit čárkou <br />\n(a případně libovolným počtem bílých znaků).");
        termyInfo.setContentAreaFilled(false);

        pravidlaSmazat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/delete_16.png"))); // NOI18N
        pravidlaSmazat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pravidlaSmazatActionPerformed(evt);
            }
        });

        pravidlaInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/info_16.png"))); // NOI18N
        pravidlaInfo.setToolTipText("<html>\nPravidla je možné zadat i ručně - přímo do pole. <br />\nJednotlivé řádky pravidel musí mít správný formát:<br />\nneterm --> řetězec | ... |  řetězec<br />\nMísto znaku epsilon (Unicode znak 03B5) je možné psát [eps].");
        pravidlaInfo.setContentAreaFilled(false);

        korenDrop.setFont(new java.awt.Font("DejaVu Sans", 0, 14));
        korenDrop.setBorder(javax.swing.BorderFactory.createTitledBorder("Kořen"));

        javax.swing.GroupLayout generovatGramatikuDialogLayout = new javax.swing.GroupLayout(generovatGramatikuDialog.getContentPane());
        generovatGramatikuDialog.getContentPane().setLayout(generovatGramatikuDialogLayout);
        generovatGramatikuDialogLayout.setHorizontalGroup(
            generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                        .addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 549, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                        .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 549, Short.MAX_VALUE)
                            .addComponent(genGramatika, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                        .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, generovatGramatikuDialogLayout.createSequentialGroup()
                                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, generovatGramatikuDialogLayout.createSequentialGroup()
                                        .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                                                .addComponent(jLabel3)
                                                .addGap(7, 7, 7)
                                                .addComponent(netermyMin, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel4)
                                                .addGap(6, 6, 6)
                                                .addComponent(netermyMax, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addComponent(genNetermy, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
                                        .addGap(2, 2, 2))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, generovatGramatikuDialogLayout.createSequentialGroup()
                                        .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(genTermy, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                                                .addComponent(jLabel5)
                                                .addGap(12, 12, 12)
                                                .addComponent(jLabel9)
                                                .addGap(10, 10, 10)
                                                .addComponent(termyMin, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel8)
                                                .addGap(6, 6, 6)
                                                .addComponent(termyMax, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(termySmazat, 0, 0, Short.MAX_VALUE)
                                        .addComponent(termyInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(netermySmazat, 0, 0, Short.MAX_VALUE)
                                        .addComponent(netermyInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(genPravidla, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                                        .addComponent(jLabel7)
                                        .addGap(29, 29, 29)
                                        .addComponent(jLabel10)
                                        .addGap(10, 10, 10)
                                        .addComponent(pravidlaRadkyMin, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel11)
                                        .addGap(6, 6, 6)
                                        .addComponent(pravidlaRadkyMax, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                                        .addComponent(jLabel1)
                                        .addGap(3, 3, 3)
                                        .addComponent(jLabel6)
                                        .addGap(10, 10, 10)
                                        .addComponent(pravidlaRetezcuMin, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel2)
                                        .addGap(6, 6, 6)
                                        .addComponent(pravidlaRetezcuMax, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(genKoren, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(korenDrop, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
                                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(pravidlaSmazat, 0, 0, Short.MAX_VALUE)
                                    .addComponent(pravidlaInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, generovatGramatikuDialogLayout.createSequentialGroup()
                        .addComponent(genOK, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(genZpet, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        generovatGramatikuDialogLayout.setVerticalGroup(
            generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(genGramatika)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 1, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                        .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
                            .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                                .addComponent(genNetermy)
                                .addGap(7, 7, 7)
                                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(netermyMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(netermyMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                        .addComponent(netermyInfo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(netermySmazat)
                        .addGap(22, 22, 22)))
                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                        .addComponent(termyInfo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(termySmazat)
                        .addGap(70, 70, 70))
                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                        .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                            .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                                .addComponent(genTermy)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(termyMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(termyMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel9)
                                    .addComponent(jLabel8))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(genKoren)
                            .addComponent(korenDrop, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                        .addComponent(genPravidla)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11)
                            .addComponent(pravidlaRadkyMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(pravidlaRadkyMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pravidlaRetezcuMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(pravidlaRetezcuMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1)
                            .addComponent(jLabel6)
                            .addComponent(jLabel2)))
                    .addGroup(generovatGramatikuDialogLayout.createSequentialGroup()
                        .addComponent(pravidlaInfo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pravidlaSmazat))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(generovatGramatikuDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(genZpet)
                    .addComponent(genOK))
                .addContainerGap())
        );

        generovatGramatikuDialogLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {netermyInfo, termyInfo});

        generovatGramatikuDialog.getAccessibleContext().setAccessibleParent(this);

        novaGenerovatDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        novaGenerovatDialog.setTitle("Nová gramatika");
        novaGenerovatDialog.setMinimumSize(novaGenerovatDialog.getPreferredSize());
        novaGenerovatDialog.setModal(true);
        novaGenerovatDialog.setModalExclusionType(null);
        novaGenerovatDialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                novaGenerovatDialogWindowClosing(evt);
            }
        });

        novaGenOK.setText("OK");
        novaGenOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                novaGenOKActionPerformed(evt);
            }
        });

        novaGenZpet.setText("Zpět");
        novaGenZpet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                novaGenZpetActionPerformed(evt);
            }
        });

        novaGramatikaNadpis.setFont(new java.awt.Font("Tahoma", 1, 11));
        novaGramatikaNadpis.setText("Nová gramatika");

        novaGenerovanaGroup.add(novaGramatikaRadioButton);
        novaGramatikaRadioButton.setSelected(true);
        novaGramatikaRadioButton.setText("Zadat novou gramatiku");

        novaGenerovanaGroup.add(generovatGramatikuRadioButton);
        generovatGramatikuRadioButton.setText("Vygenerovat náhodnou gramatiku");

        javax.swing.GroupLayout novaGenerovatDialogLayout = new javax.swing.GroupLayout(novaGenerovatDialog.getContentPane());
        novaGenerovatDialog.getContentPane().setLayout(novaGenerovatDialogLayout);
        novaGenerovatDialogLayout.setHorizontalGroup(
            novaGenerovatDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, novaGenerovatDialogLayout.createSequentialGroup()
                .addContainerGap(215, Short.MAX_VALUE)
                .addComponent(novaGenOK, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(novaGenZpet, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(novaGenerovatDialogLayout.createSequentialGroup()
                .addGap(131, 131, 131)
                .addComponent(novaGramatikaNadpis)
                .addContainerGap(130, Short.MAX_VALUE))
            .addGroup(novaGenerovatDialogLayout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(novaGenerovatDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(generovatGramatikuRadioButton)
                    .addGroup(novaGenerovatDialogLayout.createSequentialGroup()
                        .addComponent(novaGramatikaRadioButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(146, Short.MAX_VALUE))
        );
        novaGenerovatDialogLayout.setVerticalGroup(
            novaGenerovatDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, novaGenerovatDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(novaGramatikaNadpis)
                .addGap(30, 30, 30)
                .addComponent(novaGramatikaRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(generovatGramatikuRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE)
                .addGroup(novaGenerovatDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(novaGenZpet)
                    .addComponent(novaGenOK))
                .addContainerGap())
        );

        novaGenerovatDialog.getAccessibleContext().setAccessibleParent(this);

        novaGramatika1_2_3Dialog.setModal(true);
        novaGramatika1_2_3Dialog.setModalExclusionType(null);
        novaGramatika1_2_3Dialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                novaGramatika1_2_3DialogWindowClosing(evt);
            }
        });

        novaGramatikaNadpis1.setFont(new java.awt.Font("Tahoma", 1, 11));
        novaGramatikaNadpis1.setText("Nová gramatika - neterminály");

        netermNovaTextField.setFont(new java.awt.Font("DejaVu Sans", 0, 14));
        netermNovaTextField.setBorder(javax.swing.BorderFactory.createTitledBorder("Neterminál"));

        netermyNovaDalsi.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/right_16.png"))); // NOI18N
        netermyNovaDalsi.setText("Další");
        netermyNovaDalsi.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        netermyNovaDalsi.setMaximumSize(new java.awt.Dimension(69, 33));
        netermyNovaDalsi.setMinimumSize(new java.awt.Dimension(69, 33));
        netermyNovaDalsi.setPreferredSize(new java.awt.Dimension(69, 33));
        netermyNovaDalsi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                netermyNovaDalsiActionPerformed(evt);
            }
        });

        netermyNovaZpet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/left_16_red.png"))); // NOI18N
        netermyNovaZpet.setText("Zpět");
        netermyNovaZpet.setMaximumSize(new java.awt.Dimension(69, 33));
        netermyNovaZpet.setMinimumSize(new java.awt.Dimension(69, 33));
        netermyNovaZpet.setPreferredSize(new java.awt.Dimension(69, 33));
        netermyNovaZpet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                netermyNovaZpetActionPerformed(evt);
            }
        });

        pridatNeterm.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/right_16.png"))); // NOI18N
        pridatNeterm.setMnemonic(Event.ENTER);
        pridatNeterm.setText("Přidat");
        pridatNeterm.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        pridatNeterm.setMaximumSize(new java.awt.Dimension(69, 33));
        pridatNeterm.setMinimumSize(new java.awt.Dimension(69, 33));
        pridatNeterm.setPreferredSize(new java.awt.Dimension(69, 33));
        pridatNeterm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pridatNetermActionPerformed(evt);
            }
        });

        netermyNovaList.setBorder(javax.swing.BorderFactory.createTitledBorder("Neterminály"));
        netermyNovaList.setModel(listModel);
        netermyNovaList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        netermyNovaList.setToolTipText("Vyber neterminál, který bude kořenem gramatiky.");
        jScrollPane6.setViewportView(netermyNovaList);

        jScrollPaneNNH.setBorder(null);

        netermyNovaHint.setBackground(new java.awt.Color(240, 240, 240));
        netermyNovaHint.setColumns(20);
        netermyNovaHint.setEditable(false);
        netermyNovaHint.setFont(new java.awt.Font("Tahoma", 0, 11));
        netermyNovaHint.setLineWrap(true);
        netermyNovaHint.setRows(5);
        netermyNovaHint.setText("V seznamu vlevo označ neterminál, který má být kořenem gramatiky.");
        netermyNovaHint.setWrapStyleWord(true);
        netermyNovaHint.setBorder(null);
        jScrollPaneNNH.setViewportView(netermyNovaHint);

        javax.swing.GroupLayout novaGramatika1_2_3DialogLayout = new javax.swing.GroupLayout(novaGramatika1_2_3Dialog.getContentPane());
        novaGramatika1_2_3Dialog.getContentPane().setLayout(novaGramatika1_2_3DialogLayout);
        novaGramatika1_2_3DialogLayout.setHorizontalGroup(
            novaGramatika1_2_3DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(novaGramatika1_2_3DialogLayout.createSequentialGroup()
                .addGroup(novaGramatika1_2_3DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(novaGramatika1_2_3DialogLayout.createSequentialGroup()
                        .addGroup(novaGramatika1_2_3DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(novaGramatika1_2_3DialogLayout.createSequentialGroup()
                                .addGap(140, 140, 140)
                                .addComponent(novaGramatikaNadpis1))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, novaGramatika1_2_3DialogLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(novaGramatika1_2_3DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
                                    .addComponent(netermNovaTextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE))
                                .addGap(4, 4, 4)))
                        .addGap(0, 0, 0)
                        .addGroup(novaGramatika1_2_3DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPaneNNH, 0, 0, Short.MAX_VALUE)
                            .addComponent(pridatNeterm, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, novaGramatika1_2_3DialogLayout.createSequentialGroup()
                        .addContainerGap(311, Short.MAX_VALUE)
                        .addComponent(netermyNovaZpet, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(netermyNovaDalsi, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        novaGramatika1_2_3DialogLayout.setVerticalGroup(
            novaGramatika1_2_3DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(novaGramatika1_2_3DialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(novaGramatika1_2_3DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(novaGramatika1_2_3DialogLayout.createSequentialGroup()
                        .addComponent(novaGramatikaNadpis1)
                        .addGap(18, 18, Short.MAX_VALUE)
                        .addComponent(netermNovaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(pridatNeterm, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(novaGramatika1_2_3DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPaneNNH, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(novaGramatika1_2_3DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(netermyNovaZpet, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(netermyNovaDalsi, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        novaGramatika1_2_3Dialog.getAccessibleContext().setAccessibleParent(this);

        novaGramatika4Dialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                novaGramatika4DialogWindowClosing(evt);
            }
        });

        novaGramatikaNadpis2.setFont(new java.awt.Font("Tahoma", 1, 11));
        novaGramatikaNadpis2.setText("Nová gramatika - pravidla");

        levaStranaCombo.setBorder(javax.swing.BorderFactory.createTitledBorder("Levá strana"));
        levaStranaCombo.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                levaStranaComboPropertyChange(evt);
            }
        });

        pravaStranaCombo.setBorder(javax.swing.BorderFactory.createTitledBorder("Pravá strana"));

        pravidloNovaText.setEditable(false);
        pravidloNovaText.setFont(new java.awt.Font("DejaVu Sans", 0, 14));
        pravidloNovaText.setBorder(javax.swing.BorderFactory.createTitledBorder("Pravidlo"));

        pravidlaNovaText.setColumns(20);
        pravidlaNovaText.setEditable(false);
        pravidlaNovaText.setFont(new java.awt.Font("DejaVu Sans", 0, 14));
        pravidlaNovaText.setRows(5);
        pravidlaNovaText.setBorder(javax.swing.BorderFactory.createTitledBorder("Pravidla"));
        jScrollPane7.setViewportView(pravidlaNovaText);

        pravidlaDalsi.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/right_16.png"))); // NOI18N
        pravidlaDalsi.setText("Další");
        pravidlaDalsi.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        pravidlaDalsi.setMaximumSize(new java.awt.Dimension(69, 33));
        pravidlaDalsi.setMinimumSize(new java.awt.Dimension(69, 33));
        pravidlaDalsi.setPreferredSize(new java.awt.Dimension(69, 33));
        pravidlaDalsi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pravidlaDalsiActionPerformed(evt);
            }
        });

        pravidlaZpet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/left_16_red.png"))); // NOI18N
        pravidlaZpet.setText("Zpět");
        pravidlaZpet.setMaximumSize(new java.awt.Dimension(69, 33));
        pravidlaZpet.setMinimumSize(new java.awt.Dimension(69, 33));
        pravidlaZpet.setPreferredSize(new java.awt.Dimension(69, 33));
        pravidlaZpet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pravidlaZpetActionPerformed(evt);
            }
        });

        pridatSymbol.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/right_16.png"))); // NOI18N
        pridatSymbol.setMnemonic(Event.ENTER);
        pridatSymbol.setText("Přidat");
        pridatSymbol.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        pridatSymbol.setMaximumSize(new java.awt.Dimension(69, 33));
        pridatSymbol.setMinimumSize(new java.awt.Dimension(69, 33));
        pridatSymbol.setPreferredSize(new java.awt.Dimension(69, 33));
        pridatSymbol.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pridatSymbolActionPerformed(evt);
            }
        });

        pridatPravidlo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/right_16.png"))); // NOI18N
        pridatPravidlo.setMnemonic(Event.ENTER);
        pridatPravidlo.setText("Přidat");
        pridatPravidlo.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        pridatPravidlo.setMaximumSize(new java.awt.Dimension(69, 33));
        pridatPravidlo.setMinimumSize(new java.awt.Dimension(69, 33));
        pridatPravidlo.setPreferredSize(new java.awt.Dimension(69, 33));
        pridatPravidlo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pridatPravidloActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout novaGramatika4DialogLayout = new javax.swing.GroupLayout(novaGramatika4Dialog.getContentPane());
        novaGramatika4Dialog.getContentPane().setLayout(novaGramatika4DialogLayout);
        novaGramatika4DialogLayout.setHorizontalGroup(
            novaGramatika4DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, novaGramatika4DialogLayout.createSequentialGroup()
                .addGroup(novaGramatika4DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(novaGramatika4DialogLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(pravidlaZpet, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pravidlaDalsi, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(novaGramatika4DialogLayout.createSequentialGroup()
                        .addGroup(novaGramatika4DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(novaGramatika4DialogLayout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addGroup(novaGramatika4DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(novaGramatika4DialogLayout.createSequentialGroup()
                                        .addGap(162, 162, 162)
                                        .addComponent(novaGramatikaNadpis2))
                                    .addGroup(novaGramatika4DialogLayout.createSequentialGroup()
                                        .addGroup(novaGramatika4DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(pravaStranaCombo, 0, 295, Short.MAX_VALUE)
                                            .addComponent(levaStranaCombo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(pridatSymbol, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(novaGramatika4DialogLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(novaGramatika4DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jScrollPane7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)
                                    .addComponent(pravidloNovaText, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pridatPravidlo, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        novaGramatika4DialogLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {levaStranaCombo, pravaStranaCombo});

        novaGramatika4DialogLayout.setVerticalGroup(
            novaGramatika4DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(novaGramatika4DialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(novaGramatikaNadpis2)
                .addGap(18, 18, 18)
                .addComponent(levaStranaCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(novaGramatika4DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pravaStranaCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pridatSymbol, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(novaGramatika4DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pravidloNovaText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pridatPravidlo, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(novaGramatika4DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pravidlaZpet, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pravidlaDalsi, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        novaGramatika4DialogLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {levaStranaCombo, pravaStranaCombo});

        novaGramatika4Dialog.getAccessibleContext().setAccessibleParent(this);

        novaGramatika5Dialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                novaGramatika5DialogWindowClosing(evt);
            }
        });

        novaGramatikaNadpis3.setFont(new java.awt.Font("Tahoma", 1, 11));
        novaGramatikaNadpis3.setText("Nová gramatika - přehled");

        gramatikaPrehled.setColumns(20);
        gramatikaPrehled.setEditable(false);
        gramatikaPrehled.setFont(new java.awt.Font("DejaVu Sans", 0, 14));
        gramatikaPrehled.setRows(5);
        jScrollPane8.setViewportView(gramatikaPrehled);

        prehledZpet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/left_16_red.png"))); // NOI18N
        prehledZpet.setText("Zpět");
        prehledZpet.setMaximumSize(new java.awt.Dimension(69, 33));
        prehledZpet.setMinimumSize(new java.awt.Dimension(69, 33));
        prehledZpet.setPreferredSize(new java.awt.Dimension(69, 33));
        prehledZpet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prehledZpetActionPerformed(evt);
            }
        });

        prehledHotovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/tick_16.png"))); // NOI18N
        prehledHotovo.setText("Hotovo");
        prehledHotovo.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        prehledHotovo.setMargin(new java.awt.Insets(2, 14, 2, 4));
        prehledHotovo.setMaximumSize(new java.awt.Dimension(69, 33));
        prehledHotovo.setMinimumSize(new java.awt.Dimension(69, 33));
        prehledHotovo.setPreferredSize(new java.awt.Dimension(69, 33));
        prehledHotovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prehledHotovoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout novaGramatika5DialogLayout = new javax.swing.GroupLayout(novaGramatika5Dialog.getContentPane());
        novaGramatika5Dialog.getContentPane().setLayout(novaGramatika5DialogLayout);
        novaGramatika5DialogLayout.setHorizontalGroup(
            novaGramatika5DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(novaGramatika5DialogLayout.createSequentialGroup()
                .addGroup(novaGramatika5DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(novaGramatika5DialogLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE))
                    .addGroup(novaGramatika5DialogLayout.createSequentialGroup()
                        .addGap(145, 145, 145)
                        .addComponent(novaGramatikaNadpis3))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, novaGramatika5DialogLayout.createSequentialGroup()
                        .addContainerGap(280, Short.MAX_VALUE)
                        .addComponent(prehledZpet, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(prehledHotovo, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        novaGramatika5DialogLayout.setVerticalGroup(
            novaGramatika5DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(novaGramatika5DialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(novaGramatikaNadpis3)
                .addGap(12, 12, 12)
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(novaGramatika5DialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(prehledZpet, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(prehledHotovo, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11))
        );

        novaGramatika5Dialog.getAccessibleContext().setAccessibleParent(this);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Transformátor");
        setName("transformace"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jScrollPane1.setAutoscrolls(true);
        jScrollPane1.setMinimumSize(new java.awt.Dimension(10, 10));
        jScrollPane1.setPreferredSize(new java.awt.Dimension(10, 10));

        jTextArea1.setColumns(20);
        jTextArea1.setFont(new java.awt.Font("DejaVu Sans", 0, 14)); // NOI18N
        jTextArea1.setRows(5);
        jTextArea1.setText("({S,A,B,C},{a,b,c},S,P)\nP:\nA --> ab | A | SC | [eps]\nB --> ABC | abc | [eps]\nS --> C | ABc");
        jTextArea1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Výchozí gramatika", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP));
        jTextArea1.setMinimumSize(new java.awt.Dimension(16, 48));
        jTextArea1.setName("jTextArea1"); // NOI18N
        jScrollPane1.setViewportView(jTextArea1);

        statusPanel.setMaximumSize(new java.awt.Dimension(32767, 16));
        statusPanel.setMinimumSize(new java.awt.Dimension(100, 16));
        statusPanel.setPreferredSize(new java.awt.Dimension(883, 16));

        status.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        status.setLabelFor(status);
        status.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        status.setMaximumSize(new java.awt.Dimension(0, 16));
        status.setMinimumSize(new java.awt.Dimension(0, 16));
        status.setPreferredSize(new java.awt.Dimension(100, 16));

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(status, javax.swing.GroupLayout.DEFAULT_SIZE, 863, Short.MAX_VALUE)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(status, javax.swing.GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE)
        );

        status.getAccessibleContext().setAccessibleParent(statusPanel);

        jTextArea2.setColumns(20);
        jTextArea2.setEditable(false);
        jTextArea2.setFont(new java.awt.Font("DejaVu Sans", 0, 14));
        jTextArea2.setRows(5);
        jTextArea2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Transformovaná gramatika", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP));
        jTextArea2.setName("jTextArea2"); // NOI18N
        jScrollPane2.setViewportView(jTextArea2);

        ulozit1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/save_16_small.png"))); // NOI18N
        ulozit1.setText("Uložit");
        ulozit1.setMargin(new java.awt.Insets(2, 2, 2, 4));
        ulozit1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ulozit1ActionPerformed(evt);
            }
        });

        pouzit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/left_16.png"))); // NOI18N
        pouzit.setText("Použít");
        pouzit.setMargin(new java.awt.Insets(2, 2, 2, 4));
        pouzit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pouzitActionPerformed(evt);
            }
        });

        ulozit2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/save_16_small.png"))); // NOI18N
        ulozit2.setText("Uložit");
        ulozit2.setMargin(new java.awt.Insets(2, 2, 2, 4));
        ulozit2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ulozit2ActionPerformed(evt);
            }
        });

        nahrat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/folder_16.png"))); // NOI18N
        nahrat.setText("Nahrát");
        nahrat.setIconTextGap(2);
        nahrat.setMargin(new java.awt.Insets(2, 2, 2, 4));
        nahrat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nahratActionPerformed(evt);
            }
        });

        fav1.setText("nic");
        fav1.setComponentPopupMenu(vyberAkciMenu);
        fav1.setMargin(new java.awt.Insets(2, 5, 2, 5));
        fav1.setName("fav1"); // NOI18N
        fav1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fav1ActionPerformed(evt);
            }
        });

        fav2.setText("nic");
        fav2.setComponentPopupMenu(vyberAkciMenu);
        fav2.setMargin(new java.awt.Insets(2, 5, 2, 5));
        fav2.setName("fav2"); // NOI18N
        fav2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fav2ActionPerformed(evt);
            }
        });

        fav3.setText("nic");
        fav3.setComponentPopupMenu(vyberAkciMenu);
        fav3.setMargin(new java.awt.Insets(2, 5, 2, 5));
        fav3.setName("fav3"); // NOI18N
        fav3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fav3ActionPerformed(evt);
            }
        });

        smazat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/delete_16.png"))); // NOI18N
        smazat.setText("Smazat");
        smazat.setMargin(new java.awt.Insets(2, 2, 2, 4));
        smazat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                smazatActionPerformed(evt);
            }
        });

        gramatikaMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/document_16.png"))); // NOI18N
        gramatikaMenu.setText("Gramatika");
        gramatikaMenu.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        gramatikaMenu.setIconTextGap(1);
        gramatikaMenu.setMargin(new java.awt.Insets(0, 5, 0, 5));

        novaGramatikaMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        novaGramatikaMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/document_16.png"))); // NOI18N
        novaGramatikaMenu.setText("Nová gramatika..");
        novaGramatikaMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                novaGramatikaMenuActionPerformed(evt);
            }
        });
        gramatikaMenu.add(novaGramatikaMenu);

        nahratMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        nahratMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/folder_16.png"))); // NOI18N
        nahratMenu.setText("Nahrát ..");
        nahratMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nahratMenuActionPerformed(evt);
            }
        });
        gramatikaMenu.add(nahratMenu);

        ulozitMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/save_16.png"))); // NOI18N
        ulozitMenu.setText("Uložit..");

        ulozit2Menu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        ulozit2Menu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/save_16_small_2.png"))); // NOI18N
        ulozit2Menu.setText("Uložit transformovanou gramatiku");
        ulozit2Menu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ulozit2MenuActionPerformed(evt);
            }
        });
        ulozitMenu.add(ulozit2Menu);

        ulozit1Menu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        ulozit1Menu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/save_16_small_1.png"))); // NOI18N
        ulozit1Menu.setText("Uložit původní gramatiku");
        ulozit1Menu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ulozit1MenuActionPerformed(evt);
            }
        });
        ulozitMenu.add(ulozit1Menu);

        gramatikaMenu.add(ulozitMenu);

        exportMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/gear_16.png"))); // NOI18N
        exportMenu.setText("Exportovat výsledek do..");

        toXmlMenu.setText("XML");
        toXmlMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toXmlMenuActionPerformed(evt);
            }
        });
        exportMenu.add(toXmlMenu);

        toLatexMenu.setText("LaTeX");
        toLatexMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toLatexMenuActionPerformed(evt);
            }
        });
        exportMenu.add(toLatexMenu);

        toHtmlMenu.setText("(X)HTML");
        toHtmlMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toHtmlMenuActionPerformed(evt);
            }
        });
        exportMenu.add(toHtmlMenu);

        toBisonMenu.setText("Bison");
        toBisonMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toBisonMenuActionPerformed(evt);
            }
        });
        exportMenu.add(toBisonMenu);

        gramatikaMenu.add(exportMenu);
        gramatikaMenu.add(jSeparator1);

        konecMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        konecMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/stop_16.png"))); // NOI18N
        konecMenu.setText("Konec");
        konecMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                konecMenuActionPerformed(evt);
            }
        });
        gramatikaMenu.add(konecMenu);

        jMenuBar1.add(gramatikaMenu);

        transformaceMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/gear_16.png"))); // NOI18N
        transformaceMenu.setText("Transformace");
        transformaceMenu.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        transformaceMenu.setIconTextGap(1);
        transformaceMenu.setMargin(new java.awt.Insets(0, 5, 0, 5));

        identita.setText("identita");
        identita.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                identitaActionPerformed(evt);
            }
        });
        transformaceMenu.add(identita);
        identita.getAccessibleContext().setAccessibleParent(transformaceMenu);

        jMenu4.setText("na redukovanou gramatiku");

        nenormovane.setText("odstranit nenormované neterminály");
        nenormovane.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nenormovaneActionPerformed(evt);
            }
        });
        jMenu4.add(nenormovane);

        nedosazitelne.setText("odstranit nedosažitelné symboly");
        nedosazitelne.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nedosazitelneActionPerformed(evt);
            }
        });
        jMenu4.add(nedosazitelne);

        naRedukovanou.setText("celá transformace");
        naRedukovanou.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                naRedukovanouActionPerformed(evt);
            }
        });
        jMenu4.add(naRedukovanou);

        transformaceMenu.add(jMenu4);

        jMenu3.setText("na vlastní gramatiku");

        epsilon.setText("eliminace epsilon pravidel");
        epsilon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                epsilonActionPerformed(evt);
            }
        });
        jMenu3.add(epsilon);

        jednoducha.setText("odstranění jednoduchých pravidel");
        jednoducha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jednoduchaActionPerformed(evt);
            }
        });
        jMenu3.add(jednoducha);

        redukce.setText("převod na redukovanou gramatiku");
        redukce.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                redukceActionPerformed(evt);
            }
        });
        jMenu3.add(redukce);

        naVlastni.setText("celá transformace");
        naVlastni.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                naVlastniActionPerformed(evt);
            }
        });
        jMenu3.add(naVlastni);

        transformaceMenu.add(jMenu3);

        chomsky.setText("do Chomského NF");
        chomsky.setToolTipText("Každá gramatika musí být před transformací zbavena epsilon a jednoduchých pravidel.");
        chomsky.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chomskyActionPerformed(evt);
            }
        });
        transformaceMenu.add(chomsky);

        jMenu5.setText("do Greibachové NF");

        levaRekurze.setText("odstranění levé rekurze");
        levaRekurze.setToolTipText("Výchozí gramatika musí být vlastní.");
        levaRekurze.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                levaRekurzeActionPerformed(evt);
            }
        });
        jMenu5.add(levaRekurze);

        greibachova.setText("celá transformace");
        greibachova.setToolTipText("Výchozí gramatika musí být vlastní.");
        greibachova.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                greibachovaActionPerformed(evt);
            }
        });
        jMenu5.add(greibachova);

        transformaceMenu.add(jMenu5);

        jMenu1.setText("LL transformace");

        vytykani.setText("levá faktorizace");
        vytykani.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vytykaniActionPerformed(evt);
            }
        });
        jMenu1.add(vytykani);

        rohovaSubstituce.setText("rohová substituce");
        rohovaSubstituce.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rohovaSubstituceActionPerformed(evt);
            }
        });
        jMenu1.add(rohovaSubstituce);

        transformaceMenu.add(jMenu1);

        mezivysledek.setSelected(true);
        mezivysledek.setText("Vypisovat mezivýsledek");
        transformaceMenu.add(mezivysledek);

        jMenuBar1.add(transformaceMenu);

        helpMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/info_16.png"))); // NOI18N
        helpMenu.setText("O Programu");
        helpMenu.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        helpMenu.setMargin(new java.awt.Insets(0, 5, 0, 5));

        napovedaMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
        napovedaMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/help_16.png"))); // NOI18N
        napovedaMenu.setText("Nápověda");
        helpMenu.add(napovedaMenu);

        oProgramu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/info_16.png"))); // NOI18N
        oProgramu.setText("O Programu");
        oProgramu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                oProgramuActionPerformed(evt);
            }
        });
        helpMenu.add(oProgramu);

        jMenuBar1.add(helpMenu);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(fav3, javax.swing.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
                        .addGap(94, 94, 94))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ulozit1)
                            .addComponent(nahrat, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(fav1, javax.swing.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
                            .addComponent(fav2, javax.swing.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(smazat, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(ulozit2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(pouzit, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addGap(7, 7, 7)))
                .addGap(0, 0, 0)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 883, Short.MAX_VALUE)
            .addComponent(statusPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {nahrat, pouzit, smazat, ulozit1, ulozit2});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 462, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ulozit1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(nahrat, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(70, 70, 70)
                        .addComponent(fav1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(fav2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(fav3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 462, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ulozit2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pouzit, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(smazat, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void nahratMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nahratMenuActionPerformed
        int retVal = fileChooser.showOpenDialog(this);
        status.setText("");
        status.setIcon(null);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            file = fileChooser.getSelectedFile();
            if (!file.exists()) {
                status.setIcon(ikonaWarning);
                status.setText("Soubor neexistuje.");
            } else {
                try {
                    puvodniGramatika = GramatikaIO.load(file);
                } catch (Exception e) {
                    status.setIcon(ikonaWarning);
                    status.setText(e.toString());
                }
            }
            if (puvodniGramatika != null) jTextArea1.setText(puvodniGramatika.toString());
            status.setIcon(ikonaOK);
            status.setText("");
        } 
}//GEN-LAST:event_nahratMenuActionPerformed

    private void ulozit2MenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ulozit2MenuActionPerformed
        status.setText("");
        status.setIcon(null);
        int retVal = fileChooser.showSaveDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            file = new File(fileChooser.getSelectedFile().getPath());
            try {
                GramatikaIO.saveAsText(file, transformovanaGramatika);
            } catch (Exception e) {
                status.setIcon(ikonaWarning);
                status.setText(e.getMessage());
            }
            status.setIcon(ikonaOK);
            status.setText("");
        }
}//GEN-LAST:event_ulozit2MenuActionPerformed

    private void konecMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_konecMenuActionPerformed
        config.saveConfiguration();
        dispose();
}//GEN-LAST:event_konecMenuActionPerformed

    private void pouzitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pouzitActionPerformed
        status.setText("");
        status.setIcon(null);
        puvodniGramatika = transformovanaGramatika;
        if (puvodniGramatika != null) {
            jTextArea1.setText(puvodniGramatika.toString());
            jTextArea2.setText(null);
        }
}//GEN-LAST:event_pouzitActionPerformed

    private void identitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_identitaActionPerformed
        nachystatGramatiku();
        if (puvodniGramatika != null) try {
            transformovanaGramatika = puvodniGramatika;
            status.setIcon(ikonaOK);
            status.setText("");
            vypsatGramatiku(puvodniGramatika.toString(), true);
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
        }
    }//GEN-LAST:event_identitaActionPerformed

    private void chomskyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chomskyActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        try {
            Object[] eliminaceArray;
            if (mezivysledek.isSelected()) {
                if (!puvodniGramatika.bezEpsilon) {
                        eliminaceArray = EliminaceEpsilon.transformuj(puvodniGramatika);
                        transformovanaGramatika = (Gramatika)eliminaceArray[0];
                        s+=hardy("ELIMINACE \u03B5-PRAVIDEL...\n\n")+laurel((String)eliminaceArray[1])+transformovanaGramatika.toString();
                        eliminaceArray = EliminaceJednoduchychP.transformuj(transformovanaGramatika);
                        transformovanaGramatika = (Gramatika)eliminaceArray[0];
                        s+=hardy("\nELIMINACE JEDNODUCHÝCH PRAVIDEL...\n\n")+laurel((String)eliminaceArray[1])+transformovanaGramatika.toString();
                        transformovanaGramatika = NaRedukovanou.transformuj(transformovanaGramatika);
                        s+=hardy("\nPŘEVEDENÍ NA REDUKOVANOU GRAMATIKU...\n\n")+transformovanaGramatika.toString();
                        transformovanaGramatika = ChomskehoNF.transformuj(transformovanaGramatika);
                        s+=hardy("\nCHOMSKÉHO NF...\n\n")+transformovanaGramatika.toString();
                        status.setText("Gramatiku bylo třeba převést na vlastní.");
                    } else {
                        if (!puvodniGramatika.bezJednoduchych) {
                            eliminaceArray = EliminaceJednoduchychP.transformuj(transformovanaGramatika);
                            transformovanaGramatika = (Gramatika)eliminaceArray[0];
                            s+=hardy("ELIMINACE JEDNODUCHÝCH PRAVIDEL...\n\n")+laurel((String)eliminaceArray[1])+transformovanaGramatika.toString();
                            transformovanaGramatika = NaRedukovanou.transformuj(transformovanaGramatika);
                            s+=hardy("\nPŘEVEDENÍ NA REDUKOVANOU GRAMATIKU...\n\n")+transformovanaGramatika.toString();
                            transformovanaGramatika = ChomskehoNF.transformuj(transformovanaGramatika);
                            s+=hardy("\nCHOMSKÉHO NF...\n\n")+transformovanaGramatika.toString();
                            status.setText("Gramatiku bylo třeba převést na vlastní.");
                        } else {
                            if (!puvodniGramatika.bezNepouzitelnych) {
                                transformovanaGramatika = NaRedukovanou.transformuj(puvodniGramatika);
                                s+=hardy("PŘEVEDENÍ NA REDUKOVANOU GRAMATIKU...\n\n")+transformovanaGramatika.toString();
                                transformovanaGramatika = ChomskehoNF.transformuj(transformovanaGramatika);
                                s+=hardy("\nCHOMSKÉHO NF...\n\n")+transformovanaGramatika.toString();
                                status.setText("Gramatiku bylo třeba převést na vlastní.");
                            } else {
                                transformovanaGramatika = ChomskehoNF.transformuj(puvodniGramatika);
                                s+=transformovanaGramatika.toString();
                            }
                        }
                    }
            } else {
                if (!puvodniGramatika.bezEpsilon) {
                        transformovanaGramatika = ChomskehoNF.transformuj
                                                 (NaRedukovanou.transformuj
                                                 ((Gramatika)EliminaceJednoduchychP.transformuj
                                                 ((Gramatika)EliminaceEpsilon.transformuj
                                                 (puvodniGramatika)[0])[0]));
                        s+=transformovanaGramatika.toString();
                        status.setText("Gramatiku bylo třeba převést na vlastní.");
                    } else {
                        if (!puvodniGramatika.bezJednoduchych) {
                            transformovanaGramatika = ChomskehoNF.transformuj
                                                      (NaRedukovanou.transformuj
                                                      ((Gramatika)EliminaceJednoduchychP.transformuj
                                                      (puvodniGramatika)[0]));
                            s+=transformovanaGramatika.toString();
                            status.setText("Gramatiku bylo třeba převést na vlastní.");
                        } else {
                            if (!puvodniGramatika.bezNepouzitelnych) {
                                transformovanaGramatika = ChomskehoNF.transformuj
                                                          (NaRedukovanou.transformuj
                                                          (puvodniGramatika));
                                s+=transformovanaGramatika.toString();
                                status.setText("Gramatiku bylo třeba převést na vlastní.");
                            } else {
                                transformovanaGramatika = ChomskehoNF.transformuj(puvodniGramatika);
                                s+=transformovanaGramatika.toString();
                            }
                        }
                    }
            }
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_chomskyActionPerformed

    private void nenormovaneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nenormovaneActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        try {
            transformovanaGramatika = NaRedukovanou.eliminujNenormovaneNetermy(puvodniGramatika);
            s+=transformovanaGramatika.toString();
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_nenormovaneActionPerformed

    private void nedosazitelneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nedosazitelneActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        try {
            transformovanaGramatika = NaRedukovanou.eliminujNedosazitelneSymboly(puvodniGramatika);
            s+=transformovanaGramatika.toString();
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_nedosazitelneActionPerformed

    private void naRedukovanouActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_naRedukovanouActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        try {
            if (mezivysledek.isSelected()) {
                transformovanaGramatika = NaRedukovanou.eliminujNenormovaneNetermy(puvodniGramatika);
                s+=hardy("ELIMINACE NENORMOVANÝCH NETERMINÁLŮ...\n\n")+transformovanaGramatika.toString();
                transformovanaGramatika = NaRedukovanou.eliminujNedosazitelneSymboly(transformovanaGramatika);
                s+=hardy("\nELIMINACE NEDOSAŽITELNÝCH SYMBOLŮ...\n\n")+transformovanaGramatika.toString();
            } else {
                transformovanaGramatika = NaRedukovanou.transformuj(puvodniGramatika);
                s+=transformovanaGramatika.toString();
            }
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_naRedukovanouActionPerformed

    private void epsilonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_epsilonActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        try {
            Object[] eliminaceArray = EliminaceEpsilon.transformuj(puvodniGramatika);
            transformovanaGramatika = (Gramatika)eliminaceArray[0];
            if (mezivysledek.isSelected()) s+=laurel((String)eliminaceArray[1]);
            s+=transformovanaGramatika.toString();
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_epsilonActionPerformed

    private void jednoduchaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jednoduchaActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        try {
            Object[] eliminaceArray = EliminaceJednoduchychP.transformuj(puvodniGramatika);
            transformovanaGramatika = (Gramatika)eliminaceArray[0];
            if (mezivysledek.isSelected()) s+=laurel((String)eliminaceArray[1]);
            s+=transformovanaGramatika.toString();
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_jednoduchaActionPerformed

    private void redukceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redukceActionPerformed
        naRedukovanouActionPerformed(evt);
    }//GEN-LAST:event_redukceActionPerformed

    private void naVlastniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_naVlastniActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        try {
            Object[] eliminaceArray;
            if (mezivysledek.isSelected()) {
                eliminaceArray = EliminaceEpsilon.transformuj(puvodniGramatika);
                transformovanaGramatika = (Gramatika)eliminaceArray[0];
                s+=hardy("ELIMINACE \u03B5-PRAVIDEL...\n\n")+laurel((String)eliminaceArray[1])+transformovanaGramatika.toString();
                eliminaceArray = EliminaceJednoduchychP.transformuj(transformovanaGramatika);
                transformovanaGramatika = (Gramatika)eliminaceArray[0];
                s+=hardy("\nELIMINACE JEDNODUCHÝCH PRAVIDEL...\n\n")+laurel((String)eliminaceArray[1])+transformovanaGramatika.toString();
                transformovanaGramatika = NaRedukovanou.transformuj(transformovanaGramatika);
                s+=hardy("\nPŘEVEDENÍ NA VLASTNÍ GRAMATIKU - REDUKCE...\n\n")+transformovanaGramatika.toString();
            } else {
                transformovanaGramatika = NaRedukovanou.transformuj
                                          ((Gramatika)EliminaceJednoduchychP.transformuj
                                          ((Gramatika)EliminaceEpsilon.transformuj
                                          (puvodniGramatika)[0])[0]);
                s+=transformovanaGramatika.toString();
            }
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_naVlastniActionPerformed

    private void levaRekurzeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_levaRekurzeActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        try {
            if (mezivysledek.isSelected()) {
                Object[] eliminaceArray;
                eliminaceArray = EliminaceEpsilon.transformuj(puvodniGramatika);
                transformovanaGramatika = (Gramatika)eliminaceArray[0];
                s+=hardy("ELIMINACE \u03B5-PRAVIDEL...\n\n")+laurel((String)eliminaceArray[1])+transformovanaGramatika.toString();
                eliminaceArray = EliminaceJednoduchychP.transformuj(transformovanaGramatika);
                transformovanaGramatika = (Gramatika)eliminaceArray[0];
                s+=hardy("\nELIMINACE JEDNODUCHÝCH PRAVIDEL...\n\n")+laurel((String)eliminaceArray[1])+transformovanaGramatika.toString();
                transformovanaGramatika = NaRedukovanou.transformuj(transformovanaGramatika);
                s+=hardy("\nPŘEVEDENÍ NA VLASTNÍ GRAMATIKU - REDUKCE...\n\n")+transformovanaGramatika.toString();
                transformovanaGramatika = GreibachoveNF.odstranLevouRekurzi(transformovanaGramatika);
                s+=hardy("\nODSTRANĚNÍ LEVÉ REKURZE...\n\n")+transformovanaGramatika.toString();
            } else {
                transformovanaGramatika = GreibachoveNF.odstranLevouRekurzi
                                          (NaRedukovanou.transformuj
                                          ((Gramatika)EliminaceJednoduchychP.transformuj
                                          ((Gramatika)EliminaceEpsilon.transformuj
                                          (puvodniGramatika)[0])[0]));
                s+=transformovanaGramatika.toString();
            }
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_levaRekurzeActionPerformed

    private void greibachovaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_greibachovaActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        try {
            if (mezivysledek.isSelected()) {
                Object[] eliminaceArray;
                eliminaceArray = EliminaceEpsilon.transformuj(puvodniGramatika);
                transformovanaGramatika = (Gramatika)eliminaceArray[0];
                s+=hardy("ELIMINACE \u03B5-PRAVIDEL...\n\n")+laurel((String)eliminaceArray[1])+transformovanaGramatika.toString();
                eliminaceArray = EliminaceJednoduchychP.transformuj(transformovanaGramatika);
                transformovanaGramatika = (Gramatika)eliminaceArray[0];
                s+=hardy("\nELIMINACE JEDNODUCHÝCH PRAVIDEL...\n\n")+laurel((String)eliminaceArray[1])+transformovanaGramatika.toString();
                transformovanaGramatika = NaRedukovanou.transformuj(transformovanaGramatika);
                s+=hardy("\nPŘEVEDENÍ NA VLASTNÍ GRAMATIKU - REDUKCE...\n\n")+transformovanaGramatika.toString();
                transformovanaGramatika = GreibachoveNF.odstranLevouRekurzi(transformovanaGramatika);
                s+=hardy("\nODSTRANĚNÍ LEVÉ REKURZE...\n\n")+transformovanaGramatika.toString();
                transformovanaGramatika = GreibachoveNF.prevedDoGNF(transformovanaGramatika);
                s+=hardy("\nPŘEVEDENÍ DO GREIBACHOVÉ NF...\n\n")+transformovanaGramatika.toString();
            } else {
                transformovanaGramatika = GreibachoveNF.transformuj
                                          (NaRedukovanou.transformuj
                                          ((Gramatika)EliminaceJednoduchychP.transformuj
                                          ((Gramatika)EliminaceEpsilon.transformuj
                                          (puvodniGramatika)[0])[0]));
                s+=transformovanaGramatika.toString();
            }
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_greibachovaActionPerformed

    private void ulozit1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ulozit1ActionPerformed
        ulozit1MenuActionPerformed(evt);
    }//GEN-LAST:event_ulozit1ActionPerformed

    private void ulozit2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ulozit2ActionPerformed
        ulozit2MenuActionPerformed(evt);
    }//GEN-LAST:event_ulozit2ActionPerformed

    private void nahratActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nahratActionPerformed
        nahratMenuActionPerformed(evt);
    }//GEN-LAST:event_nahratActionPerformed

    private void ulozit1MenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ulozit1MenuActionPerformed
        status.setText("");
        status.setIcon(null);
        int retVal = fileChooser.showSaveDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            file = new File(fileChooser.getSelectedFile().getPath());
            try {
                nachystatGramatiku();
                GramatikaIO.saveAsText(file, puvodniGramatika);//
            } catch (Exception e) {
                status.setIcon(ikonaWarning);
                status.setText(e.getMessage());
            }
            status.setIcon(ikonaOK);
            status.setText("");
        }
    }//GEN-LAST:event_ulozit1MenuActionPerformed

    private void oProgramuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_oProgramuActionPerformed
        int x = getX()+getWidth()/3;
        int y = getY()+jMenuBar1.getY()+jMenuBar1.getHeight();
        if (oProg != null) {
            oProg.setLocation(x, y);
        } else {
            oProg = new OProgramu(x, y);
        }
        oProg.setVisible(true);
    }//GEN-LAST:event_oProgramuActionPerformed

    private void identitaPopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_identitaPopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("identita");
        config.setItem(butt);
    }//GEN-LAST:event_identitaPopUpActionPerformed

    private void nenormovanePopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nenormovanePopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("nenormované");
        config.setItem(butt);
    }//GEN-LAST:event_nenormovanePopUpActionPerformed

    private void nedosazitelnePopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nedosazitelnePopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("nedosažitelné");
        config.setItem(butt);
    }//GEN-LAST:event_nedosazitelnePopUpActionPerformed

    private void neRedukovanouPopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_neRedukovanouPopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("na redukovanou");
        config.setItem(butt);
    }//GEN-LAST:event_neRedukovanouPopUpActionPerformed

    private void epsilonPopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_epsilonPopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("epsilon");
        config.setItem(butt);
    }//GEN-LAST:event_epsilonPopUpActionPerformed

    private void jednoduchaPopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jednoduchaPopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("jednoduchá");
        config.setItem(butt);
    }//GEN-LAST:event_jednoduchaPopUpActionPerformed

    private void naVlastniPopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_naVlastniPopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("na vlastní");
        config.setItem(butt);
    }//GEN-LAST:event_naVlastniPopUpActionPerformed

    private void chomskyPopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chomskyPopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("ChomskéhoNF");
        config.setItem(butt);
    }//GEN-LAST:event_chomskyPopUpActionPerformed

    private void levaRekurzePopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_levaRekurzePopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("rekurze");
        config.setItem(butt);
    }//GEN-LAST:event_levaRekurzePopUpActionPerformed

    private void greibachovaPopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_greibachovaPopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("GreibachovéNF");
        config.setItem(butt);
    }//GEN-LAST:event_greibachovaPopUpActionPerformed

    private void nicPopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nicPopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("nic");
        config.setItem(butt);
    }//GEN-LAST:event_nicPopUpActionPerformed

    private void smazatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_smazatActionPerformed
        transformovanaGramatika = null;
        jTextArea2.setText("");
        status.setText("");
        status.setIcon(null);
    }//GEN-LAST:event_smazatActionPerformed

    private void novaGramatikaMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_novaGramatikaMenuActionPerformed
        novaGenerovatDialog.setBounds(getX(), getY(), novaGenerovatDialog.getPreferredSize().width, novaGenerovatDialog.getPreferredSize().height+12);
        novaGenerovatDialog.setVisible(true);
    }//GEN-LAST:event_novaGramatikaMenuActionPerformed

    private void genZpetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genZpetActionPerformed
        generovatGramatikuDialog.setVisible(false);
        novaGenerovatDialog.setVisible(true);
    }//GEN-LAST:event_genZpetActionPerformed

    private void netermySmazatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_netermySmazatActionPerformed
        netermyText.setText(null);
    }//GEN-LAST:event_netermySmazatActionPerformed

    private void termySmazatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_termySmazatActionPerformed
        termyText.setText(null);
    }//GEN-LAST:event_termySmazatActionPerformed

    private void pravidlaSmazatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pravidlaSmazatActionPerformed
        pravidlaText.setText(null);
    }//GEN-LAST:event_pravidlaSmazatActionPerformed

    private void netermyMinPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_netermyMinPropertyChange
        SpinnerNumberModel newModel = (SpinnerNumberModel) netermyMax.getModel();
        newModel.setMinimum((Short)netermyMin.getValue());
        netermyMax.setModel(newModel);
    }//GEN-LAST:event_netermyMinPropertyChange

    private void netermyMaxPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_netermyMaxPropertyChange
        SpinnerNumberModel newModel = (SpinnerNumberModel) netermyMin.getModel();
        newModel.setMaximum((Short)netermyMax.getValue());
        netermyMin.setModel(newModel);

        newModel = (SpinnerNumberModel) pravidlaRadkyMin.getModel();
        newModel.setMaximum((Short)netermyMax.getValue());
        pravidlaRadkyMin.setModel(newModel);
    }//GEN-LAST:event_netermyMaxPropertyChange

    private void termyMinPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_termyMinPropertyChange
        SpinnerNumberModel newModel = (SpinnerNumberModel) termyMax.getModel();
        newModel.setMinimum((Short)termyMin.getValue());
        termyMax.setModel(newModel);
    }//GEN-LAST:event_termyMinPropertyChange

    private void termyMaxPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_termyMaxPropertyChange
        SpinnerNumberModel newModel = (SpinnerNumberModel) termyMin.getModel();
        newModel.setMaximum((Short)termyMax.getValue());
        termyMin.setModel(newModel);
    }//GEN-LAST:event_termyMaxPropertyChange

    private void pravidlaRadkyMinPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_pravidlaRadkyMinPropertyChange
        SpinnerNumberModel newModel = (SpinnerNumberModel) pravidlaRadkyMax.getModel();
        newModel.setMinimum((Short)pravidlaRadkyMin.getValue());
        pravidlaRadkyMax.setModel(newModel);
    }//GEN-LAST:event_pravidlaRadkyMinPropertyChange

    private void pravidlaRadkyMaxPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_pravidlaRadkyMaxPropertyChange
        SpinnerNumberModel newModel = (SpinnerNumberModel) pravidlaRadkyMin.getModel();
        newModel.setMaximum((Short)pravidlaRadkyMax.getValue());
        pravidlaRadkyMin.setModel(newModel);
    }//GEN-LAST:event_pravidlaRadkyMaxPropertyChange

    private void pravidlaRetezcuMinPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_pravidlaRetezcuMinPropertyChange
        SpinnerNumberModel newModel = (SpinnerNumberModel) pravidlaRetezcuMax.getModel();
        newModel.setMinimum((Short)pravidlaRetezcuMin.getValue());
        pravidlaRetezcuMax.setModel(newModel);
    }//GEN-LAST:event_pravidlaRetezcuMinPropertyChange

    private void pravidlaRetezcuMaxPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_pravidlaRetezcuMaxPropertyChange
        SpinnerNumberModel newModel = (SpinnerNumberModel) pravidlaRetezcuMin.getModel();
        newModel.setMaximum((Short)pravidlaRetezcuMax.getValue());
        pravidlaRetezcuMin.setModel(newModel);
    }//GEN-LAST:event_pravidlaRetezcuMaxPropertyChange

    private void genGramatikaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genGramatikaActionPerformed
        short nMin = (Short)netermyMin.getModel().getValue();
        short nMax = (Short)netermyMax.getModel().getValue();
        short tMin = (Short)termyMin.getModel().getValue();
        short tMax = (Short)termyMax.getModel().getValue();
        short pMin = (Short)pravidlaRadkyMin.getModel().getValue();
        short pMax = (Short)pravidlaRadkyMax.getModel().getValue();
        short rMin = (Short)pravidlaRetezcuMin.getModel().getValue();
        short rMax = (Short)pravidlaRetezcuMax.getModel().getValue();
        puvodniGramatika = new Gramatika(nMin, nMax, tMin, tMax, pMin, pMax, rMin, rMax);
        netermyText.setText(vypisSymbolu(puvodniGramatika.neterminaly));
        termyText.setText(vypisSymbolu(puvodniGramatika.terminaly));
        korenDrop.setText(puvodniGramatika.koren);
        pravidlaText.setText(vypisPravidel(puvodniGramatika.pravidla));
        netermy = puvodniGramatika.neterminaly;
        termy = puvodniGramatika.terminaly;
        pravidla = puvodniGramatika.pravidla;
        koren = puvodniGramatika.koren;
    }//GEN-LAST:event_genGramatikaActionPerformed

    private void genOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genOKActionPerformed
        if (puvodniGramatika != null) jTextArea1.setText(puvodniGramatika.toString());
        netermy = new TreeSet();
        termy = new TreeSet();
        pravidla = new TreeMap();
        koren = "";
        novaGenerovatDialog.dispose();
        generovatGramatikuDialog.dispose();
    }//GEN-LAST:event_genOKActionPerformed

    private void genNetermyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genNetermyActionPerformed
        short nMin = (Short)netermyMin.getModel().getValue();
        short nMax = (Short)netermyMax.getModel().getValue();
        netermy = Gramatika.nahodneSymboly(nMin, nMax, false, new Random());
        netermyText.setText(vypisSymbolu(netermy));
        if (allDone()) puvodniGramatika = new Gramatika(netermy, termy, koren, pravidla);
    }//GEN-LAST:event_genNetermyActionPerformed

    private void genTermyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genTermyActionPerformed
        short tMin = (Short)termyMin.getModel().getValue();
        short tMax = (Short)termyMax.getModel().getValue();
        termy = Gramatika.nahodneSymboly(tMin, tMax, true, new Random());
        termyText.setText(vypisSymbolu(termy));
        if (allDone()) puvodniGramatika = new Gramatika(netermy, termy, koren, pravidla);
    }//GEN-LAST:event_genTermyActionPerformed

    private void genPravidlaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genPravidlaActionPerformed
        String koren = "";
        if (netermy == null) // pokud nemam zadne netermy
            genNetermyActionPerformed(evt);
        if ((korenDrop.getText()!=null) && (!korenDrop.getText().equals(""))) { // koren uz mam
            koren = (String)korenDrop.getText();
        } else { // koren nemam, ale mam neterminaly a vyberu si z nich
            genKorenActionPerformed(evt);
        }
        if (termy == null) // pokud nemam zadne termy
            termy = Gramatika.nahodneSymboly((Short)termyMin.getModel().getValue(),
                                               (Short)termyMax.getModel().getValue(), true, new Random());
        short pMin = (Short)pravidlaRadkyMin.getModel().getValue();
        short pMax = (Short)pravidlaRadkyMax.getModel().getValue();
        short rMin = (Short)pravidlaRetezcuMin.getModel().getValue();
        short rMax = (Short)pravidlaRetezcuMax.getModel().getValue();
        pravidla = Gramatika.nahodnaPravidla(pMin, pMax, rMin, rMax, koren, new Random(), netermy, termy);
        pravidlaText.setText(vypisPravidel(pravidla));
        if (allDone()) puvodniGramatika = new Gramatika(netermy, termy, koren, pravidla);
    }//GEN-LAST:event_genPravidlaActionPerformed

    private void pravidlaTextPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_pravidlaTextPropertyChange
        if ((netermy == null) || (termy == null)) {
            pravidlaText.setText("Nevím, co jsou neterminály a terminály.");
        } else {
            try {
                pravidla = Gramatika.parsePravidla(new BufferedReader(new StringReader(pravidlaText.getText())), netermy, termy);
            } catch (Exception e) {
                pravidlaText.append(e.getMessage());
            }
        }
        if (allDone()) puvodniGramatika = new Gramatika(netermy, termy, koren, pravidla);
    }//GEN-LAST:event_pravidlaTextPropertyChange

    private void genKorenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genKorenActionPerformed
        Random generatorCisel = new Random();
        if (!netermy.isEmpty())
        {
            int i = generatorCisel.nextInt(netermy.size());
            koren = (String)netermy.toArray()[i];
            korenDrop.setText(koren);
        }
        if (allDone()) puvodniGramatika = new Gramatika(netermy, termy, koren, pravidla);
    }//GEN-LAST:event_genKorenActionPerformed

    private void netermyTextPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_netermyTextPropertyChange
        netermy.clear();
        netermy.addAll(java.util.Arrays.asList(netermyText.getText().split(",")));
        genKorenActionPerformed(null);
//        genPravidlaActionPerformed(null);
        if (allDone()) puvodniGramatika = new Gramatika(netermy, termy, koren, pravidla);
    }//GEN-LAST:event_netermyTextPropertyChange

    private void termyTextPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_termyTextPropertyChange
        termy.clear();
        termy.addAll(java.util.Arrays.asList(termyText.getText().split(",")));
//        genPravidlaActionPerformed(null);
        if (allDone()) puvodniGramatika = new Gramatika(netermy, termy, koren, pravidla);
    }//GEN-LAST:event_termyTextPropertyChange

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // ulozit novy config
        config.saveConfiguration();
    }//GEN-LAST:event_formWindowClosing

    private void fav1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fav1ActionPerformed
        favButtonClick(fav1.getText());
    }//GEN-LAST:event_fav1ActionPerformed

    private void fav2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fav2ActionPerformed
        favButtonClick(fav2.getText());
    }//GEN-LAST:event_fav2ActionPerformed

    private void fav3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fav3ActionPerformed
        favButtonClick(fav3.getText());
    }//GEN-LAST:event_fav3ActionPerformed

    private void toXmlMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toXmlMenuActionPerformed
        status.setText("");
        status.setIcon(null);
        int retVal = fileChooser.showSaveDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            file = new File(fileChooser.getSelectedFile().getPath());
            try {
                GramatikaIO.saveAsXml(file, transformovanaGramatika);
            } catch (Exception e) {
                status.setIcon(ikonaWarning);
                status.setText(e.getMessage());
            }
            status.setIcon(ikonaOK);
            status.setText("");
        }
    }//GEN-LAST:event_toXmlMenuActionPerformed

    private void toBisonMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toBisonMenuActionPerformed
        status.setText("");
        status.setIcon(null);
        int retVal = fileChooser.showSaveDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            file = new File(fileChooser.getSelectedFile().getPath());
            try {
                GramatikaIO.saveAsBison(file, transformovanaGramatika);
            } catch (Exception e) {
                status.setIcon(ikonaWarning);
                status.setText(e.getMessage());
            }
            status.setIcon(ikonaOK);
            status.setText("");
        }
    }//GEN-LAST:event_toBisonMenuActionPerformed

    private void novaGenOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_novaGenOKActionPerformed
        if (generovatGramatikuRadioButton.isSelected()) {
            generovatGramatikuDialog.setBounds(getX(), getY(), generovatGramatikuDialog.getPreferredSize().width, generovatGramatikuDialog.getPreferredSize().height+12);
            novaGramatika1_2_3Dialog.dispose();
            novaGenerovatDialog.setVisible(false);
            generovatGramatikuDialog.setVisible(true);
        }
        if (novaGramatikaRadioButton.isSelected()) {
            if (!netermyDialog) netermyTermyDialog(true);
            netermy.clear();
            novaGramatika1_2_3Dialog.setBounds(getX(), getY(), novaGramatika1_2_3Dialog.getPreferredSize().width, novaGramatika1_2_3Dialog.getPreferredSize().height+12);
            generovatGramatikuDialog.dispose();
            novaGenerovatDialog.setVisible(false);
            novaGramatika1_2_3Dialog.setVisible(true);
        }
    }//GEN-LAST:event_novaGenOKActionPerformed

    private void novaGenZpetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_novaGenZpetActionPerformed
        novaGramatika1_2_3Dialog.dispose();
        generovatGramatikuDialog.dispose();
        novaGenerovatDialog.dispose();
    }//GEN-LAST:event_novaGenZpetActionPerformed

    private void netermyNovaDalsiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_netermyNovaDalsiActionPerformed
        if (netermyDialog) {
            if (!symboly.isEmpty() && (netermyNovaList.getSelectedValue()!=null)) {
                netermy.clear();
                netermy.addAll(symboly);
                koren = (String)netermyNovaList.getSelectedValue();
                netermyTermyDialog(false);
            }
        } else {
            termy.clear();
            termy.addAll(symboly);
            symboly.clear();
            pravaStranaCombo.addItem("\u03B5");
            for (String neterm : netermy) {
                pravaStranaCombo.addItem(neterm);
                levaStranaCombo.addItem(neterm);
            }
            for (String term : termy) pravaStranaCombo.addItem(term);
            novaGramatika4Dialog.setBounds(getX(), getY(), novaGramatika4Dialog.getPreferredSize().width+14, novaGramatika4Dialog.getPreferredSize().height+14);
            novaGramatika4Dialog.setVisible(true);
            novaGramatika1_2_3Dialog.setVisible(false);
        }
    }//GEN-LAST:event_netermyNovaDalsiActionPerformed

    private void netermyNovaZpetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_netermyNovaZpetActionPerformed
        if (netermyDialog) {
            netermy.clear();
            symboly.clear();
            listModel.clear();
            novaGramatika1_2_3Dialog.setVisible(false);
            novaGenerovatDialog.setVisible(true);
        } else {
            termy.clear();
            netermyTermyDialog(true);
            for (String neterm : netermy)
                listModel.addElement(neterm);
            netermyNovaList.setSelectedValue(koren, true);
            symboly.addAll(netermy);
            novaGramatika4Dialog.dispose();
        }
    }//GEN-LAST:event_netermyNovaZpetActionPerformed

    private void pridatNetermActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pridatNetermActionPerformed
        String text = netermNovaTextField.getText();
        if (!text.isEmpty() && !netermy.contains("text") && !text.equals("[eps]")
                && !text.equals("\u03B5")) {
            if (!netermy.contains(text)) { 
                symboly.add(text);
                netermNovaTextField.setText("");
                listModel.addElement(text);
            }
        }
    }//GEN-LAST:event_pridatNetermActionPerformed

    private void pravidlaDalsiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pravidlaDalsiActionPerformed
        puvodniGramatika = new Gramatika(netermy, termy, koren, pravidla);
        gramatikaPrehled.setText(puvodniGramatika.toString());
        novaGramatika5Dialog.setBounds(getX(), getY(), novaGramatika5Dialog.getPreferredSize().width, novaGramatika5Dialog.getPreferredSize().height+12);
        novaGramatika5Dialog.setVisible(true);
        novaGramatika4Dialog.setVisible(false);
    }//GEN-LAST:event_pravidlaDalsiActionPerformed

    private void pravidlaZpetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pravidlaZpetActionPerformed
        pravidla = new TreeMap();
        pravidlo = new ArrayList();
        pravaStrana = new HashSet();
        levaStranaCombo.removeAllItems();
        pravaStranaCombo.removeAllItems();
        novaGramatika5Dialog.dispose();
        novaGramatika1_2_3Dialog.setVisible(true);
        novaGramatika4Dialog.setVisible(false);
    }//GEN-LAST:event_pravidlaZpetActionPerformed

    private void pridatSymbolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pridatSymbolActionPerformed
        //////kontrola multi epsilonovych
        if ((levaStranaCombo.getSelectedIndex() > -1) && 
             !pravidloNovaText.getText().endsWith("\u03B5") &&
             ((pravidloNovaText.getText().endsWith(" --> ")) ||
             (!((String)pravaStranaCombo.getSelectedItem()).equals("\u03B5")))) {
            pravidloNovaText.setText(pravidloNovaText.getText()+(String)pravaStranaCombo.getSelectedItem());
            pravidlo.add((String)pravaStranaCombo.getSelectedItem());
        }
    }//GEN-LAST:event_pridatSymbolActionPerformed

    private void pridatPravidloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pridatPravidloActionPerformed
        if (!pravidlo.isEmpty()) {
            if (pravidla.containsKey(levaStrana)) {
                pravidla.get(levaStrana).add(pravidlo);
            } else {
                pravaStrana.add(pravidlo);
                pravidla.put(levaStrana, pravaStrana);
            }
            levaStranaCombo.setSelectedIndex(-1);
            levaStrana = null;
            pravidlaNovaText.setText(pravidlaNovaText.getText()+"\n"+pravidloNovaText.getText());
            pravidloNovaText.setText(null);
            pravidlo = new ArrayList();
            pravaStrana = new HashSet();
        }
    }//GEN-LAST:event_pridatPravidloActionPerformed

    private void prehledZpetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prehledZpetActionPerformed
        puvodniGramatika = null;
        novaGramatika4Dialog.setVisible(true);
        novaGramatika5Dialog.setVisible(false);
    }//GEN-LAST:event_prehledZpetActionPerformed

    private void prehledHotovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prehledHotovoActionPerformed
        // uklid a zobrazeni nove gramatiky
        jTextArea1.setText(puvodniGramatika.toString());
        pravidla = new TreeMap();
        pravaStrana = new HashSet();
        pravidlo = new ArrayList();
        levaStranaCombo.removeAllItems();
        pravaStranaCombo.removeAllItems();
        pravidlaNovaText.setText("");
        novaGenerovatDialog.dispose();
        novaGramatika1_2_3Dialog.dispose();
        novaGramatika4Dialog.dispose();
        novaGramatika5Dialog.dispose();
    }//GEN-LAST:event_prehledHotovoActionPerformed

    private void levaStranaComboPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_levaStranaComboPropertyChange
        if (levaStranaCombo.getSelectedItem()!=null) {
            levaStrana = (String)levaStranaCombo.getSelectedItem();
            pravidloNovaText.setText(levaStrana+" --> ");
            pravidlo = new ArrayList();
        } else {
            levaStrana = null;
            pravidloNovaText.setText(levaStrana);
            pravidlo.clear();
        }
    }//GEN-LAST:event_levaStranaComboPropertyChange

    private void generovatGramatikuDialogWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_generovatGramatikuDialogWindowClosing
        generovatGramatikuDialog.dispose();
    }//GEN-LAST:event_generovatGramatikuDialogWindowClosing

    private void novaGenerovatDialogWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_novaGenerovatDialogWindowClosing
        novaGramatika1_2_3Dialog.dispose();
        generovatGramatikuDialog.dispose();
        novaGenerovatDialog.dispose();
    }//GEN-LAST:event_novaGenerovatDialogWindowClosing

    private void novaGramatika1_2_3DialogWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_novaGramatika1_2_3DialogWindowClosing
        if (!netermyDialog) termy.clear();
        netermy.clear();
        symboly.clear();
        novaGramatika4Dialog.dispose();
        novaGenerovatDialog.dispose();
        novaGramatika1_2_3Dialog.dispose();
    }//GEN-LAST:event_novaGramatika1_2_3DialogWindowClosing

    private void novaGramatika4DialogWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_novaGramatika4DialogWindowClosing
        pravidla = new TreeMap();
        pravidlo = new ArrayList();
        pravaStrana = new HashSet();
        termy.clear();
        netermy.clear();
        symboly.clear();
        levaStranaCombo.removeAllItems();
        pravaStranaCombo.removeAllItems();
        novaGramatika5Dialog.dispose();
        novaGenerovatDialog.dispose();
        novaGramatika1_2_3Dialog.dispose();
        novaGramatika4Dialog.dispose();
    }//GEN-LAST:event_novaGramatika4DialogWindowClosing

    private void novaGramatika5DialogWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_novaGramatika5DialogWindowClosing
        puvodniGramatika = null;
        pravidla = new TreeMap();
        pravidlo = new ArrayList();
        pravaStrana = new HashSet();
        termy.clear();
        netermy.clear();
        symboly.clear();
        levaStranaCombo.removeAllItems();
        pravaStranaCombo.removeAllItems();
        novaGenerovatDialog.dispose();
        novaGramatika1_2_3Dialog.dispose();
        novaGramatika4Dialog.dispose();
        novaGramatika5Dialog.dispose();
    }//GEN-LAST:event_novaGramatika5DialogWindowClosing

    private void toLatexMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toLatexMenuActionPerformed
        status.setText("");
        status.setIcon(null);
        int retVal = fileChooser.showSaveDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            file = new File(fileChooser.getSelectedFile().getPath());
            try {
                GramatikaIO.saveAsLatex(file, transformovanaGramatika);
            } catch (Exception e) {
                status.setIcon(ikonaWarning);
                status.setText(e.getMessage());
            }
            status.setIcon(ikonaOK);
            status.setText("");
        }
    }//GEN-LAST:event_toLatexMenuActionPerformed

    private void toHtmlMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toHtmlMenuActionPerformed
        status.setText("");
        status.setIcon(null);
        int retVal = fileChooser.showSaveDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            file = new File(fileChooser.getSelectedFile().getPath());
            try {
                GramatikaIO.saveAsXHtml(file, transformovanaGramatika);
            } catch (Exception e) {
                status.setIcon(ikonaWarning);
                status.setText(e.getMessage());
            }
            status.setIcon(ikonaOK);
            status.setText("");
        }
    }//GEN-LAST:event_toHtmlMenuActionPerformed

    private void vytykaniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vytykaniActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        try {
            transformovanaGramatika = NaLL.vytkni(puvodniGramatika);
            s+=transformovanaGramatika.toString();
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_vytykaniActionPerformed

    private void rohovaSubstituceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rohovaSubstituceActionPerformed
        nachystatGramatiku();
        String s="";
        boolean uspesne = true;
        naVlastniActionPerformed(evt);
        puvodniGramatika = transformovanaGramatika;
        try {
            transformovanaGramatika = NaLL.rohovaSubstituce(puvodniGramatika);
            s+=transformovanaGramatika.toString();
        } catch (Exception e) {
            status.setIcon(ikonaWarning);
            status.setText(e.getMessage());
            uspesne = false;
            s+="\n\n...Další transformaci nebylo možné provést.";
        }
        vypsatGramatiku(s, uspesne);
    }//GEN-LAST:event_rohovaSubstituceActionPerformed

    private void vytykaniPopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vytykaniPopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("l. faktorizace");
        config.setItem(butt);
    }//GEN-LAST:event_vytykaniPopUpActionPerformed

    private void rohovkaPopUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rohovkaPopUpActionPerformed
        JButton butt = (JButton) vyberAkciMenu.getInvoker();
        butt.setText("rohová subs.");
        config.setItem(butt);
    }//GEN-LAST:event_rohovkaPopUpActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (Exception e) {
                    
                }
                new TransformaceApp().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem chomsky;
    private javax.swing.JMenuItem chomskyPopUp;
    private javax.swing.JMenuItem epsilon;
    private javax.swing.JMenuItem epsilonPopUp;
    private javax.swing.JMenu exportMenu;
    private javax.swing.JButton fav1;
    private javax.swing.JButton fav2;
    private javax.swing.JButton fav3;
    private javax.swing.JFileChooser fileChooser;
    private javax.swing.JButton genGramatika;
    private javax.swing.JButton genKoren;
    private javax.swing.JButton genNetermy;
    private javax.swing.JButton genOK;
    private javax.swing.JButton genPravidla;
    private javax.swing.JButton genTermy;
    private javax.swing.JButton genZpet;
    private javax.swing.JDialog generovatGramatikuDialog;
    private javax.swing.JRadioButton generovatGramatikuRadioButton;
    private javax.swing.JMenu gramatikaMenu;
    private javax.swing.JTextArea gramatikaPrehled;
    private javax.swing.JMenuItem greibachova;
    private javax.swing.JMenuItem greibachovaPopUp;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JMenuItem identita;
    private javax.swing.JMenuItem identitaPopUp;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPaneNNH;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JMenuItem jednoducha;
    private javax.swing.JMenuItem jednoduchaPopUp;
    private javax.swing.JMenuItem konecMenu;
    private javax.swing.JTextField korenDrop;
    private javax.swing.JMenuItem levaRekurze;
    private javax.swing.JMenuItem levaRekurzePopUp;
    private javax.swing.JComboBox levaStranaCombo;
    private javax.swing.JCheckBoxMenuItem mezivysledek;
    private javax.swing.JMenuItem naRedukovanou;
    private javax.swing.JMenuItem naVlastni;
    private javax.swing.JMenuItem naVlastniPopUp;
    private javax.swing.JButton nahrat;
    private javax.swing.JMenuItem nahratMenu;
    private javax.swing.JMenuItem napovedaMenu;
    private javax.swing.JMenuItem neRedukovanouPopUp;
    private javax.swing.JMenuItem nedosazitelne;
    private javax.swing.JMenuItem nedosazitelnePopUp;
    private javax.swing.JMenuItem nenormovane;
    private javax.swing.JMenuItem nenormovanePopUp;
    private javax.swing.JTextField netermNovaTextField;
    private javax.swing.JButton netermyInfo;
    private javax.swing.JSpinner netermyMax;
    private javax.swing.JSpinner netermyMin;
    private javax.swing.JButton netermyNovaDalsi;
    private javax.swing.JTextArea netermyNovaHint;
    private javax.swing.JList netermyNovaList;
    private javax.swing.JButton netermyNovaZpet;
    private javax.swing.JButton netermySmazat;
    private javax.swing.JTextArea netermyText;
    private javax.swing.JMenuItem nicPopUp;
    private javax.swing.JButton novaGenOK;
    private javax.swing.JButton novaGenZpet;
    private javax.swing.ButtonGroup novaGenerovanaGroup;
    private javax.swing.JDialog novaGenerovatDialog;
    private javax.swing.JDialog novaGramatika1_2_3Dialog;
    private javax.swing.JDialog novaGramatika4Dialog;
    private javax.swing.JDialog novaGramatika5Dialog;
    private javax.swing.JMenuItem novaGramatikaMenu;
    private javax.swing.JLabel novaGramatikaNadpis;
    private javax.swing.JLabel novaGramatikaNadpis1;
    private javax.swing.JLabel novaGramatikaNadpis2;
    private javax.swing.JLabel novaGramatikaNadpis3;
    private javax.swing.JRadioButton novaGramatikaRadioButton;
    private javax.swing.JMenuItem oProgramu;
    private javax.swing.JButton pouzit;
    private javax.swing.JComboBox pravaStranaCombo;
    private javax.swing.JButton pravidlaDalsi;
    private javax.swing.JButton pravidlaInfo;
    private javax.swing.JTextArea pravidlaNovaText;
    private javax.swing.JSpinner pravidlaRadkyMax;
    private javax.swing.JSpinner pravidlaRadkyMin;
    private javax.swing.JSpinner pravidlaRetezcuMax;
    private javax.swing.JSpinner pravidlaRetezcuMin;
    private javax.swing.JButton pravidlaSmazat;
    private javax.swing.JTextArea pravidlaText;
    private javax.swing.JButton pravidlaZpet;
    private javax.swing.JTextField pravidloNovaText;
    private javax.swing.JButton prehledHotovo;
    private javax.swing.JButton prehledZpet;
    private javax.swing.JButton pridatNeterm;
    private javax.swing.JButton pridatPravidlo;
    private javax.swing.JButton pridatSymbol;
    private javax.swing.JMenuItem redukce;
    private javax.swing.JMenuItem rohovaSubstituce;
    private javax.swing.JMenuItem rohovkaPopUp;
    private javax.swing.JButton smazat;
    private javax.swing.JLabel status;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JButton termyInfo;
    private javax.swing.JSpinner termyMax;
    private javax.swing.JSpinner termyMin;
    private javax.swing.JButton termySmazat;
    private javax.swing.JTextArea termyText;
    private javax.swing.JMenuItem toBisonMenu;
    private javax.swing.JMenuItem toHtmlMenu;
    private javax.swing.JMenuItem toLatexMenu;
    private javax.swing.JMenuItem toXmlMenu;
    private javax.swing.JMenu transformaceMenu;
    private javax.swing.JButton ulozit1;
    private javax.swing.JMenuItem ulozit1Menu;
    private javax.swing.JButton ulozit2;
    private javax.swing.JMenuItem ulozit2Menu;
    private javax.swing.JMenu ulozitMenu;
    private javax.swing.JPopupMenu vyberAkciMenu;
    private javax.swing.JMenuItem vytykani;
    private javax.swing.JMenuItem vytykaniPopUp;
    // End of variables declaration//GEN-END:variables

    private OProgramu oProg;
    Border netermBorder = javax.swing.BorderFactory.createTitledBorder("Neterminál");
    Border termBorder = javax.swing.BorderFactory.createTitledBorder("Terminál");
    Border netermyBorder = javax.swing.BorderFactory.createTitledBorder("Neterminály");
    Border termyBorder = javax.swing.BorderFactory.createTitledBorder("Terminály");
    DefaultListModel listModel = new DefaultListModel();
    boolean netermyDialog = true;
    File file;
    Configuration config;
    Gramatika puvodniGramatika;
    Gramatika transformovanaGramatika;
    ImageIcon ikonaWarning = new ImageIcon(getClass().getResource("icons/warning_16.png"));
    ImageIcon ikonaOK = new ImageIcon(getClass().getResource("icons/tick_16.png"));
    TreeSet<String> netermy = new TreeSet();
    TreeSet<String> termy = new TreeSet();
    TreeSet<String> symboly = new TreeSet();
    TreeMap<String,HashSet<ArrayList<String>>> pravidla = new TreeMap();
    HashSet<ArrayList<String>> pravaStrana = new HashSet();
    ArrayList<String> pravidlo = new ArrayList();
    String koren = "";
    String levaStrana;

    private void nachystatGramatiku()
    {
        status.setText("");
        status.setIcon(null);
        if ((puvodniGramatika == null) || (!puvodniGramatika.toString().equals(jTextArea1.getText())))
            try {
                puvodniGramatika = new Gramatika(new BufferedReader(new StringReader(jTextArea1.getText())));
            } catch (Exception e) {
                status.setIcon(ikonaWarning);
                status.setText(e.getMessage());
            }
        transformovanaGramatika = null;
    }

    private void vypsatGramatiku(String s, boolean uspesne)
    {
        if (uspesne) {
            status.setIcon(ikonaOK);
            status.setText("");
        }
        jTextArea2.setText(s);
    }

    private String vypisSymbolu(TreeSet<String> symboly)
    {
        String ret = "";
        for (String symbol : symboly)
        {
            ret += symbol+", ";
        }
        ret = ret.substring(0, ret.length()-1);
        return ret;
    }

    private String vypisPravidel(TreeMap<String,HashSet<ArrayList<String>>> pravidla)
    {
        String ret = "";
        for (String klic: pravidla.keySet())
        {
            ret += klic + " --> ";
            for (ArrayList<String> pravidlo: pravidla.get(klic))
            {
                String prav = pravidlo.toString();
                prav = prav.substring(1, prav.length()-1);
                ret += prav.replace(", ", "") + " | ";
            }
            ret = ret.substring(0, ret.length()-3);
            ret += "\n";
        }
        return ret.substring(0, ret.length()-1);
    }

    private void favButtonClick(String transformace)
    {
        if (transformace.equals("identita")) identitaActionPerformed(null);
        if (transformace.equals("nenormované")) nenormovaneActionPerformed(null);
        if (transformace.equals("nedosažitelné")) nedosazitelneActionPerformed(null);
        if (transformace.equals("na redukovanou")) naRedukovanouActionPerformed(null);
        if (transformace.equals("epsilon")) epsilonActionPerformed(null);
        if (transformace.equals("jednoduchá")) jednoduchaActionPerformed(null);
        if (transformace.equals("na vlastní")) naVlastniActionPerformed(null);
        if (transformace.equals("ChomskéhoNF")) chomskyActionPerformed(null);
        if (transformace.equals("rekurze")) levaRekurzeActionPerformed(null);
        if (transformace.equals("GreibachovéNF")) greibachovaActionPerformed(null);
        if (transformace.equals("l. faktorizace")) vytykaniActionPerformed(null);
        if (transformace.equals("rohová subs.")) rohovaSubstituceActionPerformed(null);
    }

    private boolean allDone()
    {
        if (!netermy.isEmpty() && !termy.isEmpty() && !pravidla.isEmpty() && !koren.equals(""))
            return true;
        return false;
    }

    /*
     * pripravit dialog na netermy-true nebo termy-false
     * (popisky, hint)
     * smazat set symboly
     */
    private void netermyTermyDialog(boolean netermy)
    {
        if (netermy) {
            netermyDialog = true;
            novaGramatikaNadpis1.setText("Nová gramatika - neterminály");
            netermNovaTextField.setBorder(netermBorder);
            netermyNovaList.setBorder(netermyBorder);
            netermyNovaHint.setText("V seznamu vlevo označ neterminál, který má"
            +" být kořenem gramatiky.\nNení možné přidat '[eps]' nebo '\u03B5'.");
            netermyNovaList.setEnabled(true);
            symboly.clear();
        } else {
            netermyDialog = false;
            novaGramatikaNadpis1.setText("Nová gramatika - terminály");
            netermNovaTextField.setBorder(termBorder);
            netermyNovaList.setBorder(termyBorder);
            netermyNovaHint.setText("Symboly, které patří do neterminálů, není"+
            " možné přidat do terminálů.\nNelze přidat '[eps]' nebo '\u03B5'.");
            netermyNovaList.setEnabled(false);
            symboly.clear();
        }
        listModel.clear();
    }

    /*
     * otaguje string kurzivou
     * pro pouziti s html verzi vypisu - vyzaduje neprijemnou drbacku s gui
     */
    private String laurel(String s)
    {
        //return "<i>"+s+"</i>";
        return s;
    }

    /*
     * otaguje string tucne
     */
    private String hardy(String s)
    {
        //return "<b>"+s+"</b>";
        return s;
    }
}
